<template>
  <div>
    <nav-header></nav-header>
    <div class="container">
      <div class="page-title-normal">
        <h2 class="page-title-h2"><span>check out</span></h2>
      </div>
      <!-- 进度条 -->
      <div class="check-step">
        <ul>
          <li class="cur"><span>Confirm</span> address</li>
          <li class="cur"><span>View your</span> order</li>
          <li class="cur"><span>Make</span> payment</li>
          <li class="cur"><span>Order</span> confirmation</li>
        </ul>
      </div>

      <div class="order-create">
        <div class="order-create-pic"><img src="/static/img/ok-2.png"></div>
        <div class="order-create-main">
          <h3>Congratulations! <br>Your order is under processing!</h3>
          <p>
            <span>Order ID：{{orderInfo.orderId}}</span>
            <span>Order total：{{orderInfo.orderTotal}}</span>
          </p>
          <div class="order-create-btn-wrap">
            <div class="btn-l-wrap">
              <a href="javascript:;" class="btn btn--m">Cart List</a>
            </div>
            <div class="btn-r-wrap">
              <a href="javascript:;" class="btn btn--m">Goods List</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <nav-footer></nav-footer>
  </div>
</template>

<script>
  import {currency} from '../assets/js/currency'
  import NavHeader from '../components/Header'
  import NavFooter from '../components/Footer'
  import axios from 'axios'

  export default {
    name: "OrderSuccess",
    data() {
      return {
        orderInfo: {},
        routeOrderId: this.$route.query.orderId
      }
    },
    components: {
      NavHeader, NavFooter
    },
    methods: {
      getInfo() {
        if (!this.routeOrderId) {
          alert("未传入订单号")
          return
        }

        axios.get("/users/getOrderInfo", {
          params: {
            orderId: this.routeOrderId
          }
        }).then(res => {
          if (res.data.status == 0) {
            this.orderInfo = res.data.result
            this.orderInfo.orderTotal = currency(this.orderInfo.orderTotal)
          } else {
            alert(res.data.msg)
          }
        }).catch(res => {
          alert(res.msg)
        })
      }
    },
    mounted() {
      this.getInfo()
    }
  }
</script>
